<?php
ob_start(); // 开启输出缓冲
// 先输出 HTML 或其他内容
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
				@font-face {
				font-family:迷你简剪纸;
				src: url(ttf/迷你简剪纸_爱给网_aigei_com.ttf);
				}
				#input1{
					bacopacity: 0.7;
					font-size: 10px;
					width: 800px;
					height: 43px;
					padding-left: 10px;
					border: 0px;
					outline: none;
				}
				#input1:focus{
					outline: none;
				}
				#input2{
					width: 25.5px;
					height: 25.5px;
					background-color:#fff;
					padding: 10px;
				}
		</style>
	</head>
	<body>
	<center>
	<!--查找文件库-->
	<form action="./liuyanyemian.php" method="get" style="padding:0px;margin: 0px;">
		<div style="width: 100%;padding-bottom: 10px;">
			<div style="display: flex;width: 798px;box-shadow: 0px 0px 3px #888888;border-radius: 10px;padding: 5px;background-color:#fff;">
				<input id="input1" type="text" name="search" placeholder="请输入查找输入内容">
				<input id="input2" type="image"  src="./img/comment-search-outline-custom.png" >
			</div>
		</div>
	</form>
	
		<?php
		        error_reporting(0);//关闭提示
				$s = $_GET['s'];//防止刷新
				require_once('./config.php');
				$con=login();
				
				//操作判断
				$jduser = $_COOKIE["jduser"];//获取cookie用户名
				$jdpassword = $_COOKIE["jdpassword"];//获取cookie用户名
				$sql="select tequan FROM user WHERE tequan='admin' and 用户名='$jduser' and 密码='$jdpassword'";
				$panduan=mysqli_query($con,$sql);
				$row = mysqli_fetch_array($panduan);
				if (mysqli_num_rows($panduan) == NULL)
				{
					header("Location:feifalaiyuan.html");
				}
						
				//删除记录
				$DL = $_POST["neirong"];
				if (!$con)
				{
					die('MYSQL链接失败: ' . mysqli_error());
				}
				else
				{
					if ($DL != NULL)
					{
						$shanchujilu="DELETE FROM chat WHERE id='$DL'";
						mysqli_query($con,$shanchujilu);
						echo '<script> alert("已删除"); </script>';
					}
					elseif($s!=NULL and $DL==NULL)
					{echo '<script> alert("失败"); </script>';}
				}		
				
				//通过
				$transit = $_POST["transit"];
				$id2 = $_POST["id2"];
				if (!$con)
				{
					die('MYSQL链接失败: ' . mysqli_error());
				}
				else
				{
					if ($transit!=NULL)
					{	
						$shanchujilu="UPDATE chat SET transit='true' WHERE id='$id2'";
						mysqli_query($con,$shanchujilu);
						echo '<script> alert("已通行"); </script>';
					}
					elseif($s!=NULL and $transit==NULL)
					{echo '<script> alert("通行失败"); </script>';}
				}
				
				//查找内容，否则就返回所有
				$search = $_GET['search'];//防止刷新
				$search=str_ireplace("<","&lt;",$search);//转义
				$search=str_ireplace(">","&gt;",$search);
			   if (!$con)
				{
					die('MYSQL链接失败: ' . mysqli_error());
				}
				else
				{
					if($search != NULL)
					{
						//输出所有搜索结果
						$sql = "SELECT * FROM chat where neirong like '%$search%' ";
						$result = mysqli_query($con,$sql);
						while($row = mysqli_fetch_array($result))
						{
							if($row['transit'] == "true")
							{
							  echo 
							 "<div style='height: auto;width: 800px;margin:0px 0px 15px 0px;background-color: #ffffff;padding: 5px 0px 15px 0px;text-align: left;box-shadow: 0px 0px 3px #888888;border-radius: 10px;'>".
								"<div style='text-align: left;display: flex;padding: 0px 15px 0px 15px;margin:15px 0px 0px 0px;height: 60px;'>".
									"<img src='http://q1.qlogo.cn/g?b=qq&nk=".$row['QQ']."&s=640' style='width: 45px;height:45px;margin: 0px;padding: 0px;border: 1px solid #00214f;'/>".
									"<div style='margin: 0px 0px 0px 10px;'>".
										"<p style='height: 20px;margin: 0px;padding: 0px;color: #000000;font-size:17px;font-weight:bold;font-family: 微软雅黑;'>".$row['yonghuming']."</p>".	
										"<p style='text-align: center;margin:5px 0px 0px 0px;padding: 1px 3px 1px 3px;color: #ffffff;font-size:10px;font-weight:bold;font-family: 微软雅黑;background-color: #00214f;'>"."IP:".$row['ip']."</p>".
									"</div>".
								"</div>".
								"<hr style='border: 1px solid #A9A9A9;padding: 0px;margin: 0px 15px 5px 15px;'>".
								"<div style='text-align: left;padding:0px 15px 0px 15px;margin:0px;'>".
									"<p style='margin: 15px 0px 0px 0px;padding: 0px;text-align: left;color: #000000;font-size:17px;font-family: 微软雅黑;font-weight:bold;'>".$row['neirong']."</p>".
								"</div>".
								"<div style='text-align: left;display: flex;padding:0px;margin:10px 0px 0px 10px;'>".
									"<form action='liuyanyemian.php' method='post' style='width: 40px;display: flex;'>".
										"<input type='hidden' name='neirong' value='".$row['id']."'>".
										"<input style='width: 25.5px;height: 25.5px;background-color:#00214f;padding: 10px;border-radius:5px;' type='image'  src='img/delete-forever-outline.png'>".
									"</form>".
									"<p style='color: #2E8B57;font-weight:bold;font-family: 微软雅黑;margin:12px 0px 0px 10px ;'>已通过<p/>".
								"</div>".
							 "</div>";
							}
							elseif($row['transit'] == "false")
							{
								 echo 
								 "<div style='height: auto;width: 800px;margin:0px 0px 15px 0px;background-color: #ffffff;padding: 5px 0px 15px 0px;text-align: left;box-shadow: 0px 0px 3px #888888;border-radius: 10px;'>".
									 "<div style='text-align: left;display: flex;padding: 0px 15px 0px 15px;margin:15px 0px 0px 0px;height: 60px;'>".
										"<img src='http://q1.qlogo.cn/g?b=qq&nk=".$row['QQ']."&s=640' style='width: 45px;height:45px;margin: 0px;padding: 0px;border: 1px solid #00214f;'/>".
										"<div style='margin: 0px 0px 0px 10px;'>".
											"<p style='height: 20px;margin: 0px;padding: 0px;color: #000000;font-size:17px;font-weight:bold;font-family: 微软雅黑;'>".$row['yonghuming']."</p>".	
											"<p style='text-align: center;margin:5px 0px 0px 0px;padding: 1px 3px 1px 3px;color: #ffffff;font-size:10px;font-weight:bold;font-family: 微软雅黑;background-color: #00214f;'>"."IP:".$row['ip']."</p>".
										"</div>".
									 "</div>".
									 "<hr style='border: 1px solid #A9A9A9;padding: 0px;margin: 0px 15px 5px 15px;'>".
									 "<div style='text-align: left;padding:0px 15px 0px 15px;margin:0px;'>".
										"<p style='margin: 15px 0px 0px 0px;padding: 0px;text-align: left;color: #000000;font-size:17px;font-family: 微软雅黑;font-weight:bold;'>".$row['neirong']."</p>".
									 "</div>".
									"<div style='text-align: left;display: flex;padding:0px;margin:10px 0px 0px 10px;'>".
										"<form action='liuyanyemian.php' method='post' style='width: 40px;display: flex;'>".
											"<input type='hidden' name='neirong' value='".$row['id']."'>".
											"<input style='width: 25.5px;height: 25.5px;background-color:#00214f;padding: 10px;border-radius:5px;' type='image'  src='img/delete-forever-outline.png'>".
										"</form>".
										"<form action='liuyanyemian.php' method='post' style='width: 40px;display: flex;'>".
											"<input type='hidden' name='id2' value='".$row['id']."'>".
											"<input type='hidden' name='transit' value='".$row['transit']."'>".
											"<input style='height: 45px;background-color:#00214f;padding: 10px;border-radius:5px;margin-left: 10px;color:#ffffff;font-weight:bold;font-family: 微软雅黑;' type='submit' value='通过'>".
										"</form>".
									"</div>".
								 "</div>";
							}
						}
					}
					else
					{	
					 //输出有内容	
					 $sql = "SELECT * FROM chat order by id desc;";
					 $result = mysqli_query($con,$sql);
					 while($row = mysqli_fetch_array($result))
					   {
						   if($row['transit'] == "true")
						   {
							  echo 
							 "<div style='height: auto;width: 800px;margin:0px 0px 15px 0px;background-color: #ffffff;padding: 5px 0px 15px 0px;text-align: left;box-shadow: 0px 0px 3px #888888;border-radius: 10px;'>".

								"<div style='text-align: left;display: flex;padding: 0px 15px 0px 15px;margin:15px 0px 0px 0px;height: 60px;'>".
									"<img src='http://q1.qlogo.cn/g?b=qq&nk=".$row['QQ']."&s=640' style='width: 45px;height:45px;margin: 0px;padding: 0px;border: 1px solid #00214f;'/>".
									"<div style='margin: 0px 0px 0px 10px;'>".
										"<p style='height: 20px;margin: 0px;padding: 0px;color: #000000;font-size:17px;font-weight:bold;font-family: 微软雅黑;'>".$row['yonghuming']."</p>".	
										"<p style='text-align: center;margin:5px 0px 0px 0px;padding: 1px 3px 1px 3px;color: #ffffff;font-size:10px;font-weight:bold;font-family: 微软雅黑;background-color: #00214f;'>"."IP:".$row['ip']."</p>".
									"</div>".
								"</div>".
								"<hr style='border: 1px solid #A9A9A9;padding: 0px;margin: 0px 15px 5px 15px;'>".
								"<div style='text-align: left;padding:0px 15px 0px 15px;margin:0px;'>".
									"<p style='margin: 15px 0px 0px 0px;padding: 0px;text-align: left;color: #000000;font-size:17px;font-family: 微软雅黑;font-weight:bold;'>".$row['neirong']."</p>".
								"</div>".
								"<div style='text-align: left;display: flex;padding:0px;margin:10px 0px 0px 10px;'>".
									"<form action='liuyanyemian.php' method='post' style='width: 40px;display: flex;'>".
										"<input type='hidden' name='neirong' value='".$row['id']."'>".
										"<input style='width: 25.5px;height: 25.5px;background-color:#00214f;padding: 10px;border-radius:5px;' type='image'  src='img/delete-forever-outline.png'>".
									"</form>".
									"<p style='color: #2E8B57;font-weight:bold;font-family: 微软雅黑;margin:12px 0px 0px 10px ;'>已通过<p/>".
								"</div>".
							 "</div>";
							}
							elseif($row['transit'] == "false")
							{
								 echo 
								 "<div style='height: auto;width: 800px;margin:0px 0px 15px 0px;background-color: #ffffff;padding: 5px 0px 15px 0px;text-align: left;box-shadow: 0px 0px 3px #888888;border-radius: 10px;'>".

									 "<div style='text-align: left;display: flex;padding: 0px 15px 0px 15px;margin:15px 0px 0px 0px;height: 60px;'>".
									 	"<img src='http://q1.qlogo.cn/g?b=qq&nk=".$row['QQ']."&s=640' style='width: 45px;height:45px;margin: 0px;padding: 0px;border: 1px solid #00214f;'/>".
									 	"<div style='margin: 0px 0px 0px 10px;'>".
									 		"<p style='height: 20px;margin: 0px;padding: 0px;color: #000000;font-size:17px;font-weight:bold;font-family: 微软雅黑;'>".$row['yonghuming']."</p>".	
									 		"<p style='text-align: center;margin:5px 0px 0px 0px;padding: 1px 3px 1px 3px;color: #ffffff;font-size:10px;font-weight:bold;font-family: 微软雅黑;background-color: #00214f;'>"."IP:".$row['ip']."</p>".
									 	"</div>".
									 "</div>".
									 "<hr style='border: 1px solid #A9A9A9;padding: 0px;margin: 0px 15px 5px 15px;'>".
									 "<div style='text-align: left;padding:0px 15px 0px 15px;margin:0px;'>".
									 	"<p style='margin: 15px 0px 0px 0px;padding: 0px;text-align: left;color: #000000;font-size:17px;font-family: 微软雅黑;font-weight:bold;'>".$row['neirong']."</p>".
									 "</div>".
									"<div style='text-align: left;display: flex;padding:0px;margin:10px 0px 0px 10px;'>".
										"<form action='liuyanyemian.php' method='post' style='width: 40px;display: flex;'>".
											"<input type='hidden' name='neirong' value='".$row['id']."'>".
											"<input style='width: 25.5px;height: 25.5px;background-color:#00214f;padding: 10px;border-radius:5px;' type='image'  src='img/delete-forever-outline.png'>".
										"</form>".
										"<form action='liuyanyemian.php' method='post' style='width: 40px;display: flex;'>".
											"<input type='hidden' name='id2' value='".$row['id']."'>".
											"<input type='hidden' name='transit' value='".$row['transit']."'>".
											"<input style='height: 45px;background-color:#00214f;padding: 10px;border-radius:5px;margin-left: 10px;color:#ffffff;font-weight:bold;font-family: 微软雅黑;' type='submit' value='通过'>".
										"</form>".
									"</div>".
								 "</div>";
							}
						}
					}
				}
		?>
		</center>
	</body>
</html>
